<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    京东搜索：<input type="text" value="刘强东">


    <script>
        /* 
            所有的标签都可以看作是element对象
            onblue和onfocus事件
         */
         const inputObj = document.querySelector("input")
         //聚焦事件
         inputObj.onfocus = function(){
             console.log("触发聚焦事件")
             if(this.value==='刘强东'){
                 //如果满足条件，设置为空字符串
                 this.value=''
             }
         }

         
         //离焦事件
         inputObj.onblur =function(){
             console.log("离开焦点")
             if(this.value===''){
                 this.value='刘强东'
             }
         }

    </script>
</body>
</html>